package com.gaga.metadata.driver;


import com.gaga.metadata.common.enums.TransFormType;
import com.gaga.metadata.convert.*;
import com.gaga.metadata.ddl.ITableDDL;
import com.gaga.metadata.ddl.MysqlTableDDL;
import com.gaga.metadata.entity.database.DataBaseTable;
import com.gaga.metadata.function.AbstractFunctionFactory;
import com.gaga.metadata.model.MysqlModelFactory;
import com.gaga.metadata.query.IDBQuery;
import com.gaga.metadata.query.MysqlQuery;

/**
 * @author liujia
 * @version 1.0
 * @date 2022/10/11 16:01
 */
public class MysqlDriver extends AbstractJdbcDriver {

    @Override
    String getDriverClass() {
        return TransFormType.Mysql.getDriverClass();
    }

    @Override
    String getValidateSql() {
        return "select 1";
    }

    @Override
    public IDBQuery getDBQuery() {
        return new MysqlQuery();
    }

    @Override
    public IDataTypeConvert getDataTypeConvert() {
        return new MysqlTypeConvert();
    }

    @Override
    public IAggTypeConvert getAggTypeConvert() {
        return null;
    }

    @Override
    public IFilterConvert getFilterConvert() {
        return new MysqlFilterConvert();
    }

    @Override
    public ITableDDL getTableDDL() {
        return new MysqlTableDDL();
    }

    @Override
    public AbstractFunctionFactory getAbstractFunctionFactory() {
        return null;
    }

    @Override
    public String getType() {
        return TransFormType.Mysql.getType();
    }

    @Override
    public String getName() {
        return TransFormType.Mysql.getType() + "数据库";
    }

    @Override
    public String getCreateTableSql(DataBaseTable table) {
        return MysqlModelFactory.modelProvider(this, table).handler(table);
    }

    @Override
    public String getSelectSql(DataBaseTable table) {
        return MysqlModelFactory.modelProvider(this, table).handler(table);
    }

}
